home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / unix / Makefile < prev    next >
Makefile  |  1994-05-21  |  9KB  |  268 lines

  1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License as
  6. # published by the Free Software Foundation; either version 2 of the
  7. # License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. # The unix-specific configure fragment writes `unix-generated' in config.make.
  20. config-generated := $(config-generated) $(unix-generated)
  21.  
  22. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  23.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/local_lim.h))))))
  24.  
  25. ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
  26. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_PARAM_H
  27. endif
  28. ifneq (,$(wildcard $(sysincludedir)/sys/limits.h))
  29. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_LIMITS_H
  30. endif
  31. ifneq (,$(wildcard $(sysincludedir)/limits.h))
  32. local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_LIMITS_H
  33. endif
  34.  
  35. $(common-objpfx)local_lim.h: $(common-objpfx)mk-local_lim
  36.     if $(dir $<)$(notdir $<) > $@-t; then mv $@-t $@; else XXX; fi
  37. $(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
  38.     cwd=`pwd`; cd $(@D); \
  39.     $(CC) $(native-CFLAGS) $(local_lim-CFLAGS) $$cwd/$< -o $(@F)
  40.  
  41. before-compile := $(before-compile) $(common-objpfx)local_lim.h
  42. common-generated := $(common-generated) local_lim.h mk-local_lim
  43.  
  44. endif
  45.  
  46. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  47.     $(patsubst %/sys/param.h,%/,\
  48.            $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/param.h))))))
  49.  
  50. before-compile := $(before-compile) $(common-objpfx)sys/param.h
  51.  
  52. $(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
  53.     -mkdir $(@D:%/=%)
  54.     (echo '#ifndef _GNU_SYS_PARAM_H';    \
  55.      echo '#define _GNU_SYS_PARAM_H 1';    \
  56.      echo '#include <endian.h>';        \
  57.      awk < $<            \
  58.        '/^#define[     ]*NULL/ { print "#ifndef NULL";    \
  59.                   print $$0;        \
  60.                   print "#endif";    \
  61.                   was_null = 1 }    \
  62.         { if (!was_null) print $$0;            \
  63.           was_null = 0 }';        \
  64.      echo '#ifndef MAXHOSTNAMELEN'; \
  65.      echo '#define MAXHOSTNAMELEN 64 /* XXX */'; \
  66.      echo '#endif /* No MAXHOSTNAMELEN.  */'; \
  67.      echo '#endif    /* sys/param.h */') > $@-tmp
  68.     mv $@-tmp $@
  69.  
  70. $(common-objpfx)param.h.c: $(sysincludedir)/sys/param.h
  71.     rm -f $@
  72.     cp $< $@
  73. $(common-objpfx)param.h.dep: $(common-objpfx)param.h.c \
  74.                  $(sysdep_dir)/unix/Makefile
  75.     $(+mkdep) -I$(sysincludedir) $<        \
  76.     | sed > $@                \
  77.           -e 's@^.*:@@'            \
  78.           -e 's@$<@@g'            \
  79.           -e 's@$(sysincludedir)/*@@g'    \
  80.           -e 's@\\$$@@'            \
  81.           -e 's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
  82.  
  83. # Get the generated definition of sys/param.h-includes.
  84. ifndef no_deps
  85. include $(common-objpfx)param.h.dep
  86. endif
  87.  
  88. # Don't preempt our own headers. 
  89. sys/param.h-includes := \
  90.   $(filter-out $(patsubst $(..)%,%,\
  91.               $(wildcard $(addprefix $(..),\
  92.                      $(sys/param.h-includes)))),\
  93.            $(sys/param.h-includes))
  94.  
  95.  
  96. .PHONY: sys/param.h-includes
  97. sys/param.h-includes: $(addprefix $(common-objpfx),$(sys/param.h-includes))
  98.  
  99. ifdef sys/param.h-includes
  100. # Copy the system files to $(common-objdir).
  101. $(addprefix $(common-objpfx),$(sys/param.h-includes)): $(common-objpfx)%: \
  102.                                $(sysincludedir)/%
  103.     -mkdir $(@D:%/=%)
  104. # Some of these files sometimes contain conflicting declarations for htons,
  105. # ntohs, etc.  They also often contain definitions of *_ENDIAN and
  106. # BYTE_ORDER, which we define ourselves in <endian.h>.
  107.     sed -e '/[     ]*[hn]to[nh][sl][     (]*/d' \
  108.         -e '/^#define[     ]*[A-Z]*_ENDIAN/d' \
  109.         -e '/^#define[     ]*BYTE_ORDER/d' \
  110.         $< > $@-t
  111.     mv $@-t $@
  112. endif
  113.  
  114. common-generated := $(common-generated) \
  115.             sys/param.h $(sys/param.h-includes) param.h.c param.h.dep
  116.  
  117.  
  118. ifeq ($(subdir),misc)
  119.  
  120. # Install system headers the system sys/param.h uses.
  121.  
  122. sysdep_headers := $(sysdep_headers) $(sys/param.h-includes)
  123.  
  124. endif # misc
  125.  
  126. endif # No sysdep sys/param.h.
  127.  
  128. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  129.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errnos.h))))))
  130.  
  131. # These need to exist before any compiling is done,
  132. # so cpp doesn't instead find the stub versions.
  133. before-compile := $(before-compile) $(common-objpfx)errnos.h 
  134.  
  135. $(common-objpfx)errnos.h: $(common-objpfx)make-errnos
  136.     $(dir $<)$(notdir $<) > $@-tmp
  137.     mv $@-tmp $@
  138.  
  139. $(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
  140.     $(common-objdir-compile)
  141.  
  142. $(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
  143.             $(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
  144.     awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
  145.     mv $@T $@
  146.  
  147. $(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h    \
  148.                    $(sysincludedir)/sys/errno.h)
  149.     cat $^ | sed -n 's/^#define[     ]*\(E[A-Z0-9][A-Z0-9]*\)[     ].*$$/\1/p' > $@-tmp
  150.     mv $@-tmp $@
  151.  
  152. common-generated := $(common-generated) \
  153.             errnos.h errnos make-errnos make-errnos.c
  154. endif
  155.  
  156. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  157.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/ioctls.h))))))
  158.  
  159. before-compile := $(before-compile) $(common-objpfx)ioctls.h
  160.  
  161. $(common-objpfx)ioctls.h: $(common-objpfx)make-ioctls
  162.     $(dir $<)$(notdir $<) > $@-tmp
  163.     mv $@-tmp $@
  164.  
  165. ioctl-includes := sys/termios.h net/nit.h
  166. ioctl-includes := $(wildcard $(addprefix $(sysincludedir)/,$(ioctl-includes)))
  167. make-ioctls-CFLAGS := $(subst /,_,$(subst .,_,\
  168.             $(patsubst $(sysincludedir)/%,-DHAVE_%,\
  169.                    $(ioctl-includes))))
  170.  
  171. $(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
  172.     cd $(@D); $(CC) $(native-CFLAGS) $(make-ioctls-CFLAGS) \
  173.             $(<:$(common-objpfx)%=%) -o $(@F)
  174.  
  175. $(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
  176.                    $(sysdep_dir)/unix/ioctls.awk \
  177.                    $(common-objpfx)ioctls
  178.     awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
  179.     mv $@T $@
  180.  
  181.  
  182. termbits.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/termbits.h)))
  183. ifeq ($(termbits.h),$(sysdep_dir)/generic/termbits.h)
  184. termbits.h := # Ignore the generic version.
  185. endif
  186.  
  187. # If there is a system-specific <termbits.h> file, we want to omit all the
  188. # symbols it defines from ioctls.  Otherwise, both ioctls.h and termbits.h
  189. # would define them.  The system-specific <termbits.h> file presumably
  190. # defines them with the same values as we find from the system's headers.
  191. # We also want to omit from ioctls the symbols defined in our own
  192. # <sys/ttydefaults.h>, to avoid multiple definition conflicts.  We use
  193. # snarf-ioctls on these files to find what symbols we want to omit.  fgrep
  194. # -xv gives all lines which do not match in their entirety; without -x,
  195. # CSTOP's presence elided TIOCSTOP.
  196.  
  197. $(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
  198.             $(sysincludedir)/sys/ioctl.h $(ioctl-includes)
  199.     $(dir $<)$(notdir $<) $(filter-out $<,$^) \
  200.     | fgrep -xv "`$(dir $<)$(notdir $<) $(termbits.h) \
  201.                         $(..)termios/sys/ttydefaults.h \
  202.              | sort | uniq`" \
  203.     | sort | uniq | tr '\012' ' ' > $@-tmp
  204.     mv $@-tmp $@
  205.  
  206. common-generated := $(common-generated) \
  207.             ioctls.h ioctls make-ioctls make-ioctls.c
  208. endif
  209.  
  210. ifeq ($(subdir),stdio)
  211. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  212.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errlist.c))))))
  213.  
  214. before-compile: $(objpfx)errlist.c
  215. $(objpfx)errlist.c: $(objpfx)make_errlist
  216.     @rm -f $@
  217.     $(dir $<)$(notdir $<) > $@-tmp
  218.     mv $@-tmp $@
  219.  
  220. $(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c
  221.     $(native-compile)
  222.  
  223. generated := $(generated) make_errlist errlist.c
  224.  
  225. endif
  226. endif # stdio
  227.  
  228. ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
  229.     $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/syscall.h))))))
  230.  
  231. # The syscall code assumes a file <syscall.h> that defines macros
  232. # `SYS_call' for syscall `call'.  Variations on this I have seen include:
  233. # it's in <sys/syscall.h>;
  234. # it's in <sys.s>;
  235. # it defines `CALL' instead of `SYS_call'.
  236. # Irix has a <syscall.h> which is not what we want, so check for <sys.s> first.
  237.  
  238. # Find a file that might have these.  NOTE: This list of possibilities is
  239. # repeated in sysdeps/unix/configure and the two should be kept in sync.
  240. syscall.h := $(firstword $(wildcard $(addprefix $(sysincludedir)/, \
  241.                         sys.s sys/sys.s \
  242.                         sys.S sys/sys.S \
  243.                         syscall.h sys/syscall.h \
  244.                         )))
  245. ifdef syscall.h
  246.  
  247. # Transmogrify any of several formats of the file into the one we want.
  248. $(common-objpfx)syscall.h: $(syscall.h)
  249.     tr '[A-Z]' '[a-z]' < $< | \
  250.     sed -e 's/[     ]sys_/ /' \
  251.         -e 's/^#define[     ]*\([a-z0-9_]*\)[     ]*/#define SYS_\1 /' \
  252.         -e 's/[     ]sys_/ SYS_/' \
  253.         -e 's/SYS_syscall_basenum/syscall_basenum/g' \
  254.         -e 's/SYS_kerncall_basenum/kerncall_basenum/g' \
  255.         -e 's/SYS_sysvoffset/sysvoffset/g' \
  256.         -e '/^#/!d' \
  257.         -e '/^#ident/d' \
  258.         -e 's-\(/\*[^*]*\)$$-\1\*/-' \
  259.     > $@-tmp
  260.     mv $@-tmp $@
  261.  
  262. before-compile := $(before-compile) $(common-objpfx)syscall.h
  263. common-generated := $(common-generated) syscall.h
  264.  
  265. endif
  266.  
  267. endif
  268.